package com.ldn.starter.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @author 李大牛家的牛 (scafel@163.com) 
 * @createDate 2024/7/9 - 16:58
 * @description ...
 **/
@Slf4j
@Component
public class RequestInterceptorImpl implements HandlerInterceptor {

    @Override
    public boolean preHandle(
            @NotNull HttpServletRequest request,
            @NotNull HttpServletResponse response,
            @NotNull Object handler
    ) throws Exception {
        log.info("preHandle request =>{} ", request.getMethod()+ " " + request.getRequestURI()+" " + request.getRemoteAddr());
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }

}